package com.bos.dao.imp;

import com.bos.dao.IRegionDao;
import com.bos.dao.base.imp.BaseDaoImp;
import com.bos.domain.Region;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Administrator
 */
@Repository
public class IRegionDaoImp extends BaseDaoImp<Region> implements IRegionDao {

    @Override
    public void saveOrUpdate(Region region) {
        this.getHibernateTemplate().saveOrUpdate(region);
    }

    @Override
    public List<Region> findAllByq(String q) {
        String hql="from Region r where r.province like ? or r.city like ? or r.district like ? or r.postcode like ?" +
                "or r.shortcode like ? or r.citycode like ?";
        return (List<Region>) this.getHibernateTemplate().find(hql,"%"+q+"%","%"+q+"%","%"+q+"%","%"+q+"%",
                "%"+q+"%","%"+q+"%");
    }

}
